<template>
  <div>

<!--    输入: <input type="text" v-model="text">-->
<!--    <button @click='send'>发送</button>-->

  </div>
</template>

<script>
export default {
  name: "tttext",
  data() {
    return {
      data1: '',
      text:''
    }
  },
  methods: {
    initWebSocket(){
      var socket = new WebSocket("ws:127.0.0.1:5000/admin")
          socket.onopen = function () {
        console.log('WebSocket open');//成功连接上Websocket
      }
          socket.onmessage = function (e) {
            alert('消息提醒: ' + e.data);//打印服务端返回的数据
          }
          socket.onclose=function(e){
            console.log(e);
            socket.close(); //关闭TCP连接
          }
    }


  },
  mounted() {
    this.initWebSocket()
  }

}
</script>

<style scoped>

</style>